from pydantic import BaseModel, EmailStr, HttpUrl
from typing import Optional
from datetime import datetime

class BasicSettings(BaseModel):
    system_name: str
    api_url: HttpUrl
    log_level: str
    auto_backup: bool

class NotificationSettings(BaseModel):
    email_enabled: bool
    smtp_server: Optional[str] = None
    smtp_port: Optional[int] = 587
    sender_email: Optional[EmailStr] = None
    email_password: Optional[str] = None

class SecuritySettings(BaseModel):
    password_expire_days: int
    login_lock_enabled: bool
    max_login_attempts: Optional[int] = None
    lock_duration: Optional[int] = None

class SystemSettingsResponse(BaseModel):
    id: int
    system_name: str
    api_url: str
    log_level: str
    auto_backup: bool
    email_enabled: bool
    smtp_server: Optional[str] = None
    smtp_port: Optional[int] = None
    sender_email: Optional[str] = None
    password_expire_days: int
    login_lock_enabled: bool
    max_login_attempts: Optional[int] = None
    lock_duration: Optional[int] = None
    updated_at: datetime
    updated_by: Optional[int] = None

    class Config:
        from_attributes = True 